package com.aabte.nettyleran.netty.http.xml.httpdecoder;

import com.aabte.nettyleran.netty.http.xml.HttpXmlResponse;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.http.FullHttpResponse;

import java.util.List;

/**
 * @author Daniel
 * @version 1.0
 * @date 2020/3/14
 */
public class HttpXmlResponseDecoder extends AbstractHttpXmlDecoder<FullHttpResponse> {
    public HttpXmlResponseDecoder(Class<?> clazz) {
        this(clazz, false);
    }

    public HttpXmlResponseDecoder(Class<?> clazz, boolean isPrint) {
        super(clazz, isPrint);
    }

    @Override
    protected void decode(ChannelHandlerContext ctx, FullHttpResponse msg, List<Object> out) throws Exception {
        Object result = decode0(ctx, msg.content());
        HttpXmlResponse httpXmlResponse = new HttpXmlResponse(msg, result);
        out.add(httpXmlResponse);
    }
}
